package com.hbm.usercenter.activity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;

import com.hbm.usercenter.R;
import com.hbm.usercenter.base.BaseActivityCommon;
import com.hbm.usercenter.utils.UIUtils;
import com.hbm.usercenter.widget.GroupPayment;

import butterknife.Bind;
import butterknife.ButterKnife;

public class PromotePayActivity extends BaseActivityCommon {

    @Bind(R.id.gp_unionPay)
    GroupPayment mGpUnionPay;
    @Bind(R.id.gp_alipay_s)
    GroupPayment mGpAlipayS;
    @Bind(R.id.gp_wechat_s)
    GroupPayment mGpWechatS;
    @Bind(R.id.gp_alipay)
    GroupPayment mGpAlipay;
    @Bind(R.id.gp_wechat)
    GroupPayment mGpWechat;
    @Bind(R.id.btn_confirm)
    Button mBtnConfirm;
    @Bind(R.id.tv_price)
    TextView mTvPrice;

    private int payMent = -1;
    public static int UNIONPAY = 0;
    public static int ALIPAYS = 1;
    public static int WECHATS = 2;
    public static int ALIPAY = 3;
    public static int WECHAT = 4;

    public static final String PRICE_DATA = "price";

    @Override
    protected void init() {
        Intent intent = getIntent();

        Bundle bundle = intent.getExtras();
        String price = bundle.getString(PRICE_DATA);
        mTvPrice.setText(price);
    }

    @Override
    protected void initView() {
        setContentView(R.layout.activity_promote_pay);
        ButterKnife.bind(this);
        initToolbar("红包互粉");
    }

    @Override
    protected void initListener() {
        mGpUnionPay.setClick(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                payMent = UNIONPAY;
                reset();
                mGpUnionPay.setIvIsCheck(true);
            }
        });
        mGpAlipayS.setClick(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                payMent = ALIPAYS;
                reset();
                mGpAlipayS.setIvIsCheck(true);
            }
        });
        mGpWechatS.setClick(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                payMent = WECHATS;
                reset();
                mGpWechatS.setIvIsCheck(true);
            }
        });
        mGpAlipay.setClick(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                payMent = ALIPAY;
                reset();
                mGpAlipay.setIvIsCheck(true);
            }
        });
        mGpWechat.setClick(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                payMent = WECHAT;
                reset();
                mGpWechat.setIvIsCheck(true);
            }
        });
        mBtnConfirm.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                pay(payMent);
            }
        });
    }

    protected void reset() {
        mGpUnionPay.setIvIsCheck(false);
        mGpAlipayS.setIvIsCheck(false);
        mGpWechatS.setIvIsCheck(false);
        mGpAlipay.setIvIsCheck(false);
        mGpWechat.setIvIsCheck(false);
    }

    protected void pay(int payMent) {
        switch (payMent) {
            case 0:
                Toast.makeText(UIUtils.getContext(), "银联在线", Toast.LENGTH_SHORT).show();
                break;
            case 1:
                Toast.makeText(UIUtils.getContext(), "支付宝扫码支付", Toast.LENGTH_SHORT).show();
                break;
            case 2:
                Toast.makeText(UIUtils.getContext(), "微信扫码支付", Toast.LENGTH_SHORT).show();
                break;
            case 3:
                Toast.makeText(UIUtils.getContext(), "支付宝服务窗支付", Toast.LENGTH_SHORT).show();
                break;
            case 4:
                Toast.makeText(UIUtils.getContext(), "微信支付", Toast.LENGTH_SHORT).show();
                break;
        }
    }
}
